//
//  IssueNowAlertController.m
//  FactorySale
//
//  Created by 主事丫环HU on 2020/8/7.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "IssueNowAlertController.h"

@interface IssueNowAlertController ()
@property (weak, nonatomic) IBOutlet UIView *tipsView;
@property (weak, nonatomic) IBOutlet UILabel *balanceLabel;
@property (weak, nonatomic) IBOutlet UILabel *moneyLabel;

@end

@implementation IssueNowAlertController
- (instancetype)init {
    if (self = [super initWithNibName:nil bundle:nil]) {
        self.modalPresentationStyle = UIModalPresentationCustom;
        self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
    self.balanceLabel.text = [NSString stringWithFormat:@"￥%@",self.model.balance];
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",self.model.compensationPrice];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self animationAlert:self.tipsView];
}

- (IBAction)cancelButtonClick:(UIButton *)sender {
    if (self.cancelButtonClick) {
        self.cancelButtonClick();
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)confirmButtonClick:(UIButton *)sender {
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"id"] = self.idStr;
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetWorkTool POST:grantsTransferFactory param:param success:^(id dic) {
        if (self.okButtonClick) {
            self.okButtonClick();
        }
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    } other:^(id dic) {
        ShowToastWithText(dic[@"msg"]);
        if (self.cancelButtonClick) {
            self.cancelButtonClick();
        }
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    } fail:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    } needUser:YES];
    
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
